#! /bin/bash
export LANG=en_US.UTF-8

#function parse(){
#	STRNUM=$#
#	for((i=1;i<=$STRNUM;i++));do 
#		curStr=$(echo $(eval  echo \${${i}}))
#		curStr=$(echo $curStr | awk '{if(substr($1,0,16)=="-Djava.ext.dirs="){print $1}}' | awk -F '=' '{print $2}' )
#		num=$(echo $curStr| awk '{print index($1,"..")}')

#		if [[ $num != "0" ]];then
#			echo $curStr| awk '{print substr($1,0,index($1,"..")-2);}'
#		fi
#	done
#}


#STRNUM=$(ps aux | grep mq | grep broker | grep jar| grep -v "uoamp")
#parse $STRNUM


pid=$*

target_jar_file=`ps aux | grep $pid|grep -v grep |grep -v pts|grep -v notty |awk '{print $(NF-1)}'`
if [ -e "$target_jar_file" ];then
        bin_path=`dirname "$target_jar_file"`
        cd $bin_path/../
        echo `pwd`/
fi
